package cn.edu.wyu.blogmvc;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class PostDAOMock {
    private List<Post> posts = new ArrayList<>();

    public void add(Post post) {
        this.posts.add(post);
    }

    public List<Post> list() {
        return this.posts;
    }

    public boolean remove(String uuid) {
        for(int i=0; i<this.posts.size(); i++) {
            if(this.posts.get(i).getUuid().equals(uuid)) {
                this.posts.remove(i);
                return true;
            }
        }
        return false;
    }
}
